// components/HuaTiChange/HuaTiChange.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    HuaTiList:[],
    alllist:[],
    tabdata:[
      {
        title:'推荐'
      },
      {
        title:'最新',
        state:0,
      },
      {
        title:'最热',
        state:1,
      }
    ],
    active:0
  },
ready(){
  wx.request({
    url: 'http://127.0.0.1:7001/api/getzqhsqare',
    method:"GET",
    success:(res)=>{
      this.setData({
        HuaTiList:res.data.data,
        alllist:res.data.data
      })
    }
  })
},
// 

  /**
   * 组件的方法列表
   */
  methods: {
    onClick:function(e){
      let {index}=e.detail 
      let arr=this.data.alllist.filter(v=>index==1?(v.state==0):(v.state==1))
      this.setData({
        HuaTiList:(index==1 || index==2)?arr:this.data.alllist
      })

      
    },
    // 跳转话题详情 
    tohuati(e){
      let {id}=e.currentTarget.dataset
      wx.navigateTo({
        url: '/pages/huatidetail/huatidetail'
      })
      wx.setStorageSync('huati_id', id)
    }
  }
})
